package com.bj58.migrate.condition.impl;

import java.util.List;

import com.bj58.migrate.ScfProxy;
import com.bj58.sfft.cmc.entity.DispCategory;

public class CateCondition extends AbstractCondition{

	private int depth = 2;
	private int dispcateid = 9224;

	public CateCondition(){

		intConditionList();
	}

	public CateCondition( int depth, int dispcateid ){

		this.depth = depth;
		this.dispcateid = dispcateid;

		intConditionList();
	}

	@Override
	public void intConditionList(){

		try{
			List< DispCategory > list = ScfProxy.cmc_DispCategory().GetDispCategoryByParentID( dispcateid );
			if( list != null && depth > 0 ){
				for( DispCategory dispCategory : list ){
					if( dispCategory != null && dispCategory.getIsVisible() ){
						if( dispCategory.getDepth() == 1 && dispCategory.getIsVisible() ){
							if( depth == 1 ){
								conlist.add( "cateid=" + dispCategory.getInfoCateidList() );
							}
							else{
								List< DispCategory > children = ScfProxy.cmc_DispCategory().GetDispCategoryByParentID( dispCategory.getDispCategoryID() );
								if( children != null ){
									for( DispCategory child : children ){
										if( child != null && child.getIsVisible() ){
											conlist.add( "cateid=" + child.getInfoCateidList() );
										}
									}
								}
							}
						}
					}
				}
				// 对兼职类别增加学生兼职类别713（后期特殊处理）
				// if( 13941 == dispcateid ){
				// conlist.add( "cateid=" + Constant.XueShengJianZhiCateId );
				// }
			}
			else if( list != null && depth == 0 ){
				// ScfProxy.cmc_DispCategory().GetDispCategory
				if( "9224".equals( dispcateid ) ){
					conlist.add( "cateid=" + 574 );
				}
				else if( "13941".equals( dispcateid ) ){
					conlist.add( "cateid=" + 577 );
				}
				else{
					// 暂不处理
				}
			}
		}
		catch( Exception e ){
			e.printStackTrace();
		}
	}
}
